package cn.gzsxt.music.mapper;

import java.util.Map;

public class SsListProvider {
	public String insertAllSong(Map<String, Object> m_ssList) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(
				"Insert into mc_sslist (songList_id,song_id,ssList_date) select #{songList_id},mc_song.song_id,#{ssList_date} from mc_song where  song_id in (");
		String[] song_ids = ((String) m_ssList.get("song_id")).split(",");
		for (int i = 0; i < song_ids.length; i++) {
			sBuilder.append(song_ids[i] + ",");
		}
		sBuilder.deleteCharAt(sBuilder.length() - 1);
		sBuilder.append(")");
		return sBuilder.toString();
	}

	public String deleteSong(Map<String, Object> ss_List) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append("delete from mc_sslist where songList_id = #{songList_id} and song_id not in (");
		String[] song_ids = ((String) ss_List.get("song_id")).split(",");
		for (int i = 0; i < song_ids.length; i++) {
			sBuilder.append(song_ids[i] + ",");
		}
		sBuilder.deleteCharAt(sBuilder.length() - 1);
		sBuilder.append(")");
		return sBuilder.toString();
	}
}
